#include<bits/stdc++.h>
using namespace std;

const int N=1e5+5;

int t;
int n,m,L,V;
int d[N],v[N],a[N];
int p[N];

int f[N];

struct line{
    int l,r;
};

bool cmp(line x,line y)
{
    if(x.l==y.l)
        return x.r<y.r;
    return x.l<y.l;
}

vector<line> e;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);

    cin>>t;
    while(t--)
    {
        e.clear();

        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++)
            cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;i++)
            cin>>p[i];
        p[0]=-1;
        p[m+1]=1e8;

        for(int i=1;i<=n;i++)
        {
            int x=V*V-v[i]*v[i],y=2*a[i];
            if(v[i]>V&&a[i]>=0)
                e.push_back({d[i],L});
            else if(v[i]<=V&&a[i]<=0)
                continue;
            else if(a[i]>0)
                e.push_back({x/y+((x%y)?0:1)+d[i],L});
            else
                e.push_back({d[i],d[i]+x/y-((x%y)?0:1)});
        }

        int ans=0;
        vector<line> tmp;
        for(int i=0;i<(int)e.size();i++)
        {
            int l=e[i].l,r=e[i].r;
            int pos=lower_bound(p+1,p+m+2,l)-p;

            if(l>r)
                continue;

            if(p[pos]<=r)
                tmp.push_back({max(0,l),min(L,r)}),ans++;
        }

        cout<<ans<<' ';

        sort(tmp.begin(),tmp.end(),cmp);

        int R=tmp.size();
        vector<int> l(R+5),r(R+5);
        for(int i=0;i<R;i++)
            l[i+1]=tmp[i].l,r[i+1]=tmp[i].r;
        l[R+1]=r[R+1]=1e9;

        vector<int> upb(m+5);
        for(int i=1;i<=m;i++)
            upb[i]=upper_bound(l.begin()+1,l.begin()+R+1,p[i])-l.begin();

        for(int i=1;i<=m;i++)
        {
            int mn=1e9;
            int k=upb[i]-1;
            f[i]=1e9;
            for(int j=i-1;j>=0;j--)
            {
                if(j==0)
                {
                    for(;k>=1;k--)
                        mn=min(mn,r[k]);
                }
                else
                {
                    int c=upb[j];
                    for(;k>=c;k--)
                        mn=min(mn,r[k]);
                }
                if(mn<p[i])
                    break;
                f[i]=min(f[i],f[j]+1);
            }
        }

//        for(int i=1;i<=R;i++)
  //          cout<<l[i]<<' '<<r[i]<<'\n';

        ans=1e9;
        for(int i=m;i>=1;i--)
        {
            if(p[i]<l[R])
                break;

            ans=min(ans,f[i]);
        }

        cout<<m-ans<<'\n';

    }

    return 0;
}
//keda save me
//AgOH save me
//zybtxdy
